package com.by.springdoc.config;

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;

/**
 * swagger自动配置类
 */
@AutoConfiguration//标识为自动配置类
@EnableConfigurationProperties({SpringDocProperties.class})//启用属性批量绑定
public class SpringDocAutoConfigure {

    @Autowired
    SpringDocProperties docProperties;

    @Bean
    public OpenAPI customOpenAPI() {
        return new OpenAPI()
                .info(new Info()
                        .title(docProperties.getTitle())
                        .version(docProperties.getVersion())
                        .description(docProperties.getDesc()));
    }

}
